package logicGame.Cards;

import java.io.Serializable;
import logicGame.Board;
import logicGame.Player;

public class Card implements Serializable {

    boolean earth, water;
    String descrition, resource;
    int nResources, numAction, quant, code, nome;
    Action action;

    public Card(int code, int earth, int water, String descrition, String resource, int nResources, int numAction, int nome) {
        this.earth = earth == 1;
        this.water = water == 1;
        this.descrition = descrition;
        this.resource = resource;
        this.nResources = nResources;
        this.numAction = numAction;
        this.code = code;
        this.nome= nome;
        switch (code) {
            case 0:
                action = new Place();
                break;
            case 1:
                action = new Move();
                break;
            case 2:
                action = new Found();
                break;
            default:
                action = null;
                break;

        }
    }

    public void DoAction(Player p, Board b, int place, int finish) {
        action.Do(p, b, place, finish);
        numAction -= 1;
    }

    public String getDescrition() {
        return descrition;
    }

    @Override
    public String toString() {
        return "Recurso: " + resource + "\tNumero Recursos: " + nResources + "\tDescrição: " + descrition;
    }

    public boolean isEarth() {
        return earth;
    }

    public void setEarth(boolean earth) {
        this.earth = earth;
    }

    public boolean isWater() {
        return water;
    }

    public void setWater(boolean water) {
        this.water = water;
    }

    public String getResource() {
        return resource;
    }

    public void setResource(String resource) {
        this.resource = resource;
    }

    public int getnResources() {
        return nResources;
    }

    public void setnResources(int nResources) {
        this.nResources = nResources;
    }

    public int getNumAction() {
        return numAction;
    }

    public int getQuant() {
        return quant;
    }

    public void setQuant(int quant) {
        this.quant = quant;
    }

    public Action getAction() {
        return action;
    }

    public int getCode() {
        if (getAction() instanceof Move) {
            return 1;
        } else {
            return 0;
        }
    }

    public int getNome() {
        return nome;
    }
    
    

    //a partir daqui serve apenas para polimorfismo
    public int getOp() {
        return 0;
    }

    public void setOp(int op) {
    }

    public int getTimes() {
        return 0;
    }

    public void setTimes(int op) {
    }
    
}
